package com.example.xd.myijkplayer

import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import com.example.xd.myijkplayer.activity.TextureViewActivity
import com.example.xd.myijkplayer.activity.VideoViewActivity
import com.example.xd.permissionlibrary.DefayultCallPermission
import com.example.xd.permissionlibrary.FloatingPermission
import com.example.xd.permissionlibrary.floating.FloatWindowManager
import kotlinx.android.synthetic.main.activity_ijk_player.*

class IjkPlayerActivity : AppCompatActivity(), View.OnClickListener {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_ijk_player)
        btn1.setOnClickListener(this)
        btn2.setOnClickListener(this)
        btn3.setOnClickListener(this)
        btn4.setOnClickListener(this)
    }


    override fun onClick(v: View?) {
        when (v) {
            btn1 -> {
                startActivity(Intent(this, VideoViewActivity::class.java))
            }
            btn2 -> {
                if (!FloatingPermission.isFloatingPermission(this)) {
                    FloatingPermission.getFloatingPermission(this)
                }else{
                    FloatWindowManager.getInstance().applyOrShowFloatWindow(this)
                }
            }
            btn3 -> {
                if (!DefayultCallPermission.isDefaultCall(this)) {
                    DefayultCallPermission.setDefaultCall(this)
                }
            }
            btn4 -> {
                startActivity(Intent(this, TextureViewActivity::class.java))
            }
        }
    }
}
